package cn.bone.admin.base.bean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by Administrator on 2017/9/12.
 */
public class DataGrid<T> {

    private List<T> data = new ArrayList<>();
    private Integer rowCount;
    private Integer pageCount;
    private Integer currentPage;

    public List<T> getData() {
        return data;
    }

    public void setData(List<T> data) {
        this.data = data;
    }

    public Integer getRowCount() {
        return rowCount;
    }

    public void setRowCount(Integer rowCount) {
        this.rowCount = rowCount;
    }

    public Integer getPageCount() {
        return pageCount;
    }

    public void setPageCount(Integer pageCount) {
        this.pageCount = pageCount;
    }

    public Integer getCurrentPage() {
        return currentPage;
    }

    public void setCurrentPage(Integer currentPage) {
        this.currentPage = currentPage;
    }

    public static <T> DataGrid<T> dataGrid(List<T> list,int count,int page,int rows){
        DataGrid<T> dataGrid = new DataGrid<>();
        dataGrid.setData(list);
        dataGrid.setRowCount(count);
        int pageCount;
        if(count%rows==0){
            pageCount = count/rows;
        }else{
            pageCount = count/rows + 1;
        }
        dataGrid.setPageCount(pageCount);
        dataGrid.setCurrentPage(page);
        return dataGrid;
    }
}
